package com.woniuxy.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import com.woniuxy.pojo.Guest;
import com.woniuxy.pojo.Guest_yyh;
import com.woniuxy.provider.GuestProvider;

public interface GuestMapper {
	
	@Insert("insert into guest values()")
	public int addGuest(Guest guest);
	//添加住客
	@Insert("insert into guest(gname,gidcard,uid) values(#{gname},#{gidcard},#{uid})")
	int adGuest(Guest guest);
	
	@Select("SELECT guest.gid,gname,gidcard,uid,rid,checkin,checkout FROM guest,(SELECT gid,rid,checkin,checkout FROM orderdetail WHERE scheckout is null and checkin < NOW()) dd WHERE dd.gid=guest.gid")
	public List<Guest_yyh> getCheckinG();

	@Select("SELECT guest.gid,gname,gidcard,uid,rid,checkin,checkout FROM guest,(SELECT gid,rid,checkin,checkout FROM orderdetail WHERE scheckout is null and checkin < NOW()) dd WHERE dd.gid=guest.gid and guest.gname like #{message}")
	public List<Guest_yyh> selG(String message);
	
	@Select("select * from guest where gname=#{gname} and gidcard=#{gidcard}")
	public Guest findGuest(Guest guest);

	@SelectProvider(method="findGuests",type=GuestProvider.class)
	public List<Guest> findGuests(Guest guest);
	
	@Select("select * from guest where gid = #{gid}")
	public Guest findById(int gid);
}
